var t = getApp();

Page({
    data: {
        language: "",
        is_hotel: !1,
        hotel_id: "",
        store: {
            name: "",
            thumb: "",
            store_id: ""
        },
        startDate: "",
        endDate: "",
        income: {
            money_total: 0,
            sure_withdraw_money: 0
        },
        stat: {},
        integral: ""
    },
    onLoad: function(e) {
        console.log(wx.getStorageSync("integral"));
        var o = "";
        try {
            o = wx.getStorageSync("integral");
        } catch (t) {
            console.log(t);
        }
        this.setData({
            integral: o
        }), t._isTextEmpty(e.hotel_id) ? (this.setData({
            is_hotel: !1
        }), this.getStoreInfo()) : (this.setData({
            is_hotel: !0,
            hotel_id: e.hotel_id
        }), this.getHotelInfo());
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getStoreInfo: function() {
        var e = this, o = t.getNetAddresss("plugin.store-cashier.frontend.cashier.center.index");
        t._getNetWork({
            url: o,
            success: function(t) {
                var o = t.data;
                1 == o.result ? (e.setData({
                    store: o.data.store,
                    income: o.data.income
                }), e.getStat()) : wx.showToast({
                    icon: "none",
                    title: o.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getStat: function(e) {
        var o = this, n = "";
        e || (e = 0), t._isTextEmpty(this.data.hotel_id) ? (n = t.getNetAddresss("plugin.store-cashier.frontend.cashier.Statistics.index"), 
        n += "&store_id=" + o.data.store.store_id, n += "&is_time=" + e) : (n = t.getNetAddresss("plugin.hotel.frontend.cashier.Statistics.index"), 
        n += "&hotel_id=" + o.data.hotel_id, n += "&is_time=" + e), t._getNetWork({
            url: n,
            success: function(t) {
                var e = t.data;
                1 == e.result ? o.setData({
                    stat: e.data
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getStatbtn: function() {
        this.getStat(1);
    },
    getHotelInfo: function() {
        var e = this, o = t.getNetAddresss("plugin.hotel.frontend.cashier.center.index");
        o += "&hotel_id=" + this.data.hotel_id, t._getNetWork({
            url: o,
            success: function(t) {
                var o = t.data;
                1 == o.result && (e.setData({
                    store: o.data.hotel
                }), e.getStat());
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});